import {req_delete, req_get, req_upload} from "@/request/cssdrequest";
import {R} from "@/type/dto/R";
import {RP} from "@/type/dto/RP";
import {AttachmentInfoVO} from "@/type/vo/AttachmentInfoVO";


// multipartFile: UploadRawFile,
//     linkKey: string,
//     linkType: number,
//     orderIndex: number,
//     fileType: number,
//     fileVersion: number
export async function api_uploadFile(form: FormData) {
    const data = await req_upload('/file_upload/file', form);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

//export async function api_getFileBlob(id: string) {
//    const data = await req_get_blob('/file_upload', id);
//    //转成我要的json
//    console.log('data:', data);
//    return JSON.parse(data) as R<string>;
//}

//export async function api_fileDownload(id: string) {
//    const data = await req_get('/file_upload', id);
//    //转成我要的json
//    console.log('data:', data);
//    return JSON.parse(data) as R<string>;
//}

export async function api_getFileList(id: string, limit: number, page: number) {
    const data = await req_get('/file_upload/link_id', {
        id,
        limit,
        page
    });
    //file_upload/link_id?id=DT20240201230647912325
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<RP<AttachmentInfoVO>>;
}

export async function api_deleteFile(fileId: string) {
    const data = await req_delete('/file_upload/file', {
        id: fileId
    });
    //file_upload/link_id?id=DT20240201230647912325
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

